import request from "@/utils/request";
const defaultApi = (apiName) => {
    return {
        list: (params) => request.get(`/${apiName}/list`, { params }),
        page: (params) => request.get(`/${apiName}`, { params }),
        read: (id) => request.get(`/${apiName}/` + id),
        create: (id, data) => request.post(`/${apiName}`, data),
        update: (id, data) => request.put(`/${apiName}/` + id, data),
        delete: (id) => request.delete(`/${apiName}/` + id)
    }
}
export const http = {
    login: (data) => request.post('/user/login', data),
    banner: {
        ...defaultApi('banner'),
    },
    menu: {
        ...defaultApi('menu'),
    },
    role: {
        ...defaultApi('role'),
      },
    user: {
        ...defaultApi('user'),
    },
    member: {
        ...defaultApi('member'),
    },
    policy: {
      ...defaultApi('policy')
    },
    school: defaultApi('school'),
    college: defaultApi('college'),
    field: defaultApi('field'),
    major: {
      ...defaultApi('major'),
      createList: (data) => request.post('/major/createList', data)
    },
    course: defaultApi('course'),
}
// uploadFile
export const uploadFile = (file) => {
    const formData = new FormData()
    formData.append('file', file)
    return request({
        url: '/upload',
        method: 'post',
        data: formData
    })
}

